package com.youkeyi.ddy.cloud.common.api.application.system.login;

import com.youkeyi.ddy.cloud.common.api.application.system.login.dto.AppletLoginAuthCloudDto;
import com.youkeyi.ddy.cloud.common.api.application.system.login.param.AppletLoginAuthCloudParam;
import com.youkeyi.ddy.cloud.common.response.ResponseContent;
import com.youkeyi.ddy.cloud.common.response.ResponseObjectContent;
import io.swagger.annotations.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 小程序登录授权相关接口
 *
 * @Author liuxiawang
 * @Date 2023-02-16 11:37
 * @Location shenzhen.china
 */
@Api(tags = {"【Applet】Login"})
@RestController
@RequestMapping("/system/applet/login")
@FeignClient(value = "YOUKEYI-DDY-CLOUD-APPLICATION-SYSTEM", fallback = SystemAppletLoginFeignServiceFallback.class)
public interface SystemAppletLoginFeignService {

    /**
     * 微信小程序授权登陆.
     *
     * @return the auth code
     */
    @GetMapping("/getWxInfo/{code}")
    @ApiOperation(value = "微信小程序授权登陆", authorizations = {@Authorization("com.youkeyi.common.api.application.applet.login.AppletLoginFeignService.getWxInfo")})
    @ApiResponse(code = 200, message = "data Property in Response Body", response = AppletLoginAuthCloudDto.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "param", paramType = "query"),
    })
    public abstract AppletLoginAuthCloudDto getWxInfo(@PathVariable("code") String code);

    /**
     * 获取Token.
     *
     * @param param the param
     * @return the response content
     */
    @GetMapping(value = "/getToken")
    @ApiOperation(value = "获取Token", authorizations = {@Authorization("com.youkeyi.common.api.application.applet.login.AppletLoginFeignService.getToken")})
    @ApiResponse(code = 200, message = "data Property in Response Body", response = ResponseObjectContent.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "param", paramType = "body"),
    })
    public abstract ResponseObjectContent getToken(AppletLoginAuthCloudParam param);

    /**
     * 退出登陆.
     *
     * @return the response content
     */
    @PostMapping(value = "/logout")
    @ApiOperation(value = "退出登陆", authorizations = {@Authorization("com.youkeyi.common.api.application.applet.login.AppletLoginFeignService.logout")})
    @ApiResponse(code = 200, message = "data Property in Response Body", response = ResponseContent.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "param", paramType = "query"),
    })
    public abstract ResponseContent logout(HttpServletRequest request, HttpServletResponse response);

}
